package edu.taru.service.impl;
import edu.taru.mapper.MenuMapper;
import edu.taru.mapper.RoleMenuMapper;
import edu.taru.pojo.Menu;
import edu.taru.pojo.RoleMenu;
import edu.taru.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    MenuMapper menuMapper;
    @Autowired
    RoleMenuMapper roleMenuMapper;

    @Override
    public int addMenu(Menu menu) {
        return menuMapper.insertMenu(menu);
    }

    @Override
    public int removeMenu(Integer menuId) {
        return menuMapper.removeMenuByMenuId(menuId);
    }

    @Override
    public int updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public Menu getMenu(Integer roleId) {
        return menuMapper.getMenuByMenuId(roleId);
    }

    @Override
    public int removeRoleMenu(Integer id) {
        return roleMenuMapper.removeRoleMenuById(id) ;
    }

    @Override
    public int addRoleMenu(RoleMenu roleMenu) {
        return roleMenuMapper.insertRoleMenu(roleMenu);
    }

    @Override
    public List<Menu> getMenu() {
        return menuMapper.getMenu();
    }
    @Override
    public List<Menu> getMenuByUserId(String userId){
        return  menuMapper.getMenuByUserId(userId);
    };
}
